local skel = fk.CreateSkill {
  name = "emo__zhimangcj",
}

Fk:loadTranslationTable{
  ["emo__zhimangcj"] = "致盲吹箭",
  [":emo__zhimangcj"] = "出牌阶段限一次，或当你登场后，你可以视为使用射【杀】，对目标角色造成伤害后，其本回合使用的下一张牌无效。",

  ["@@emo__zhimangcj-turn"] = "被致盲",
  ["#emo__zhimangcj-use"] = "致盲吹箭：视为使用射【杀】，受伤目标下一张牌无效",

  ["$emo__zhimangcj1"] = "提莫队长正在待命。",
  ["$emo__zhimangcj2"] = "我去前面探探路。",
}

local U = require "packages.utility.utility"

---@param player ServerPlayer
local doShoot = function (player)
  local room = player.room
  local name = "slash"
  if Fk.all_card_types["shoot__slash"] then name = "shoot__slash" end -- 我没安装射杀！
  room:askToUseVirtualCard(player, {
    name = name, skill_name = skel.name, prompt = "#emo__zhimangcj-use", cancelable = false,
    extra_data = {bypass_distances = true, bypass_times = true, extraUse = true}
  })
end

skel:addEffect("active", {
  anim_type = "offensive",
  prompt = "#emo__zhimangcj-use",
  card_num = 0,
  target_num = 0,
  can_use = function (self, player)
    if player:usedEffectTimes(self.name, Player.HistoryPhase) == 0 then
      local slash = Fk:cloneCard("slash")
      slash:setVSPattern(skel.name, player, "slash|0|nosuit|none")
      return player:canUse(slash)
    end
  end,
  on_use = function (self, room, use)
    doShoot(use.from)
  end,
})

skel:addEffect(U.GeneralAppeared, {
  anim_type = "offensive",
  can_trigger = function (self, event, target, player, data)
    return target == player and player:hasSkill(skel.name)
  end,
  on_use = function (self, event, target, player, data)
    doShoot(player)
  end,
})

skel:addEffect(fk.Damage, {
  can_refresh = function (self, event, target, player, data)
    return target == player and not data.to.dead and data.card and table.contains(data.card.skillNames, skel.name) and data.by_user
  end,
  on_refresh = function (self, event, target, player, data)
    player.room:setPlayerMark(data.to, "@@emo__zhimangcj-turn", 1)
  end,
})

skel:addEffect(fk.CardUsing, {
  mute = true,
  is_delay_effect = true,
  can_trigger = function (self, event, target, player, data)
    return target == player and player:getMark("@@emo__zhimangcj-turn") ~= 0
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "@@emo__zhimangcj-turn", 0)
    data:removeAllTargets()
    data.toCard = nil
  end,
})

return skel
